package day10;

import java.util.InputMismatchException;
import java.util.Scanner;

//2：计算平均课时:输入总课时和课程数,计算平均课时.
// 要求捕捉输入和除法错误;如果总课时少于100,抛出课时太少的错误
public class ClassHour {
    public static void main(String[] args) {
        try {
            classHour();
        } catch (InputMismatchException e) {
            System.err.println("必须是整数：" + e);
        } catch (ArithmeticException e) {
            System.err.println("除数不能为0：" + e);
        } catch (Exception e) {
            System.err.println("其他错误：" + e);
        }
    }

    public static void classHour() throws Exception {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入总课时：");
        int sum = scan.nextInt();
        System.out.println("请输入课程数：");
        int num = scan.nextInt();
        if (sum < 100 && sum >= 0 && num >= 0) {
            System.out.println(String.format("%d/%d=%d", sum, num, sum / num));
        }
    }
}